/*
 * @Author: sdorein sdorein@163.com
 * @Date: 2024-07-26 15:04:04
 * @LastEditors: sdorein sdorein@163.com
 * @LastEditTime: 2024-08-01 11:38:36
 * @FilePath: \vite-as-editor\vite.config.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
//import globalComponents from './src/plugins/permission';
// 定义一个函数来解析路径
function resolve(dir: string) {
  return path.resolve(__dirname, dir);
}
export default defineConfig({
  plugins: [vue()],//,globalComponents],
  root: "./", // 指定应用的入口文件
  base: "./", // 静态资源的公共基础路径
  build: {
    outDir: "AS-Editor", // 输出目录
    minify: "terser", // 压缩方式
    assetsDir: "static",
    sourcemap: false,
  },
  server: {
    host: "localhost", // 开发服务器的主机名
    port: 3000, // 开发服务器的端口号
    proxy: {
      "/api": {
        target: "http://api.aseditor.fun/",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    }, // 代理配置
  },
  resolve: {
    alias: {
      "@": resolve("./src"),
      components: resolve("./src/components"),
      css: resolve("./src/assets/css"),
      iconfont: resolve("./src/assets/iconfont"),
      img: resolve("./src/assets/images"),
      utils: resolve("./src/utils"),
    }, // 模块别名配置
  },
  css: {
    preprocessorOptions: {
      /* ... */
    }, // CSS 预处理器选项
  },
  // ...其他配置
  optimizeDeps: {
    include: ['file-saver'],
  },
});
